﻿@model CustomerInfoModel

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)

<script>
    $(document).ready(function() {
        bindBootstrapTabSelectEvent('customer-edit');
    });
</script>

<div class="content">
    <div class="form-horizontal">
        <div id="customer-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("tab-info", @T("Admin.Customers.Customers.Info"), true)
                @if (Model.Id > 0)
                {
                    @Html.RenderBootstrapTabHeader("tab-activitylog", @T("Admin.Customers.Customers.ActivityLog"))
                }
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("tab-info", @TabInfo(), true)
                @if (Model.Id > 0)
                {
                    @Html.RenderBootstrapTabContent("tab-activitylog", @TabActivityLog())
                }
            </div>
        </div>
    </div>
</div>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "customer-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab name*@
<input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">

@helper TabInfo()
{
    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.Username)
                    </div>
                    <div class="col-md-9">
                        @Html.NopDisplayFor(model => model.Username)
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.OldPassword)
                    </div>
                    <div class="col-md-9">
                        <div class="input-group">
                            @Html.NopEditorFor(model => model.OldPassword)
                            @Html.ValidationMessageFor(model => model.OldPassword)
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.NewPassword)
                    </div>
                    <div class="col-md-9">
                        <div class="input-group">
                            @Html.NopEditorFor(model => model.NewPassword)
                            @Html.ValidationMessageFor(model => model.NewPassword)
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.ConfirmNewPassword)
                    </div>
                    <div class="col-md-9">
                        <div class="input-group">
                            @Html.NopEditorFor(model => model.ConfirmNewPassword)
                            @Html.ValidationMessageFor(model => model.ConfirmNewPassword)
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.TrueName)
                    </div>
                    <div class="col-md-9">
                        @Html.NopEditorFor(model => model.TrueName)
                        @Html.ValidationMessageFor(model => model.TrueName)
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3">
                        @Html.NopLabelFor(model => model.TelPhone)
                    </div>
                    <div class="col-md-9">
                        @Html.NopEditorFor(model => model.TelPhone)
                        @Html.ValidationMessageFor(model => model.TelPhone)
                    </div>
                </div>
                @*<div class="form-group">
            <div class="col-md-3">
                @Html.NopLabelFor(model => model.Gender)
            </div>
            <div class="col-md-9">
                <div class="raw">
                    <div class="col-md-1">
                        <div class="radio">
                            <label>
                                @Html.RadioButton("Gender", "M", (Model.Gender == "M"), new { id = "Gender_Male" })
                                @T("Admin.Customers.Customers.Fields.Gender.Male")
                            </label>
                        </div>
                    </div>
                    <div class="col-md-11">
                        <div class="radio">
                            <label>
                                @Html.RadioButton("Gender", "F", (Model.Gender == "F"), new { id = "Gender_Female" })
                                @T("Admin.Customers.Customers.Fields.Gender.Female")
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3">
                @Html.NopLabelFor(model => model.DateOfBirth)
            </div>
            <div class="col-md-9">
                @Html.NopEditorFor(model => model.DateOfBirth)
                @Html.ValidationMessageFor(model => model.DateOfBirth)
            </div>
        </div>*@
            </div>
        </div>
    </div>
}

@helper TabActivityLog()
{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div id="activitylog-grid"></div>

                <script>
                    $(document).ready(function () {
                        $("#activitylog-grid").kendoGrid({
                            dataSource: {
                                type: "json",
                                transport: {
                                    read: {
                                        url: "@Html.Raw(Url.Action("ListActivityLog", "Customer", new { customerId = Model.Id }))",
                                        type: "POST",
                                        dataType: "json",
                                        data: addAntiForgeryToken
                                    }
                                },
                                schema: {
                                    data: "Data",
                                    total: "Total",
                                    errors: "Errors"
                                },
                                error: function(e) {
                                    display_kendoui_grid_error(e);
                                    // Cancel the changes
                                    this.cancelChanges();
                                },
                                pageSize: @(defaultGridPageSize),
                                serverPaging: true,
                                serverFiltering: true,
                                serverSorting: true
                            },
                            pageable: {
                                refresh: true,
                                pageSizes: [@(gridPageSizes)],
                                @Html.Partial("_GridPagerMessages")
                            },
                            editable: {
                                confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                mode: "inline"
                            },
                            scrollable: false,
                            columns: [{
                                field: "ActivityLogTypeName",
                                title: "@T("Admin.Customers.Customers.ActivityLog.ActivityLogType")",
                                width: 300,
                            }, {
                                field: "IpAddress",
                                title: "@T("Admin.Customers.Customers.ActivityLog.IpAddress")",
                                width: 100
                            }, {
                                field: "Comment",
                                title: "@T("Admin.Customers.Customers.ActivityLog.Comment")"
                            }, {
                                field: "CreatedOn",
                                title: "@T("Admin.Customers.Customers.ActivityLog.CreatedOn")",
                                width: 200,
                                type: "date",
                                format: "{0:yyyy/MM/dd HH:mm:ss}"
                            }]
                        });
                    });
                </script>
            </div>
        </div>
    </div>
}